<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>脚本命令 | MyUI 4.x</title>
    <meta name="generator" content="VuePress 1.5.4">
    <link rel="icon" href="/my/favicon.ico">
    <script>
      var _hmt = _hmt || [];
      (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?c4e5f73318b5cb0c389e3d9a05f831cc";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
    <meta name="description" content="MyUI是美亚柏科旗下新德汇出品的Web前端一站式项目工程框架，专注于公检法行业中台系统快速搭建，框架已在多个项目实战检验。">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <link rel="preload" href="/my/assets/css/0.styles.810d4cba.css" as="style"><link rel="preload" href="/my/assets/js/app.2dbd0b81.js" as="script"><link rel="preload" href="/my/assets/js/493.009afff8.js" as="script"><link rel="preload" href="/my/assets/js/1350.4706a745.js" as="script">
    <link rel="stylesheet" href="/my/assets/css/0.styles.810d4cba.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/my/" class="home-link router-link-active"><img src="/my/img/logo.png" alt="MyUI 4.x" class="logo"> <span class="site-name can-hide">MyUI 4.x</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/my/guide/" class="nav-link router-link-active">
  指南
</a></div><div class="nav-item"><a href="/my/ui/components/" class="nav-link">
  组件
</a></div><div class="nav-item"><a href="/my/ui/charts/" class="nav-link">
  图表
</a></div><div class="nav-item"><a href="/my/ui/map/" class="nav-link">
  地图
</a></div><div class="nav-item"><a href="/my/ui/go/" class="nav-link">
  关系图
</a></div><div class="nav-item"><a href="/my/ui/icon/" class="nav-link">
  图标
</a></div><div class="nav-item"><a href="/my/ui/pages/" class="nav-link">
  页面
</a></div><div class="nav-item"><a href="http://newgateway.gitee.io/my-web/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  演示
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="JSDoc" class="dropdown-title"><span class="title">JSDoc</span> <span class="arrow down"></span></button> <button type="button" aria-label="JSDoc" class="mobile-dropdown-title"><span class="title">JSDoc</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my/api/components.html" class="nav-link">
  基础组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/utils.html" class="nav-link">
  工具函数
</a></li><li class="dropdown-item"><!----> <a href="/my/api/charts.html" class="nav-link">
  图表组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/map.html" class="nav-link">
  地图组件
</a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/my/guide/" class="nav-link router-link-active">
  指南
</a></div><div class="nav-item"><a href="/my/ui/components/" class="nav-link">
  组件
</a></div><div class="nav-item"><a href="/my/ui/charts/" class="nav-link">
  图表
</a></div><div class="nav-item"><a href="/my/ui/map/" class="nav-link">
  地图
</a></div><div class="nav-item"><a href="/my/ui/go/" class="nav-link">
  关系图
</a></div><div class="nav-item"><a href="/my/ui/icon/" class="nav-link">
  图标
</a></div><div class="nav-item"><a href="/my/ui/pages/" class="nav-link">
  页面
</a></div><div class="nav-item"><a href="http://newgateway.gitee.io/my-web/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  演示
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="JSDoc" class="dropdown-title"><span class="title">JSDoc</span> <span class="arrow down"></span></button> <button type="button" aria-label="JSDoc" class="mobile-dropdown-title"><span class="title">JSDoc</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my/api/components.html" class="nav-link">
  基础组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/utils.html" class="nav-link">
  工具函数
</a></li><li class="dropdown-item"><!----> <a href="/my/api/charts.html" class="nav-link">
  图表组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/map.html" class="nav-link">
  地图组件
</a></li></ul></div></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>开发指南</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/my/guide/access.html" class="sidebar-link">权限控制</a></li><li><a href="/my/guide/app.html" class="sidebar-link">子应用微服务</a></li><li><a href="/my/guide/cmd.html" aria-current="page" class="active sidebar-link">脚本命令</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#安装依赖" class="sidebar-link">安装依赖</a></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#初始化项目" class="sidebar-link">初始化项目</a></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#预编译主题" class="sidebar-link">预编译主题</a></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#生成代码" class="sidebar-link">生成代码</a></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#生成路由配置" class="sidebar-link">生成路由配置</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#主应用路由" class="sidebar-link">主应用路由</a></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#子应用路由" class="sidebar-link">子应用路由</a></li></ul></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#启动开发环境" class="sidebar-link">启动开发环境</a></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#编译主应用" class="sidebar-link">编译主应用</a></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#启动预览服务" class="sidebar-link">启动预览服务</a></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#代码校验" class="sidebar-link">代码校验</a></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#运行单元测试" class="sidebar-link">运行单元测试</a></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#构建桥类库" class="sidebar-link">构建桥类库</a></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#启动文档服务" class="sidebar-link">启动文档服务</a></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#发布项目" class="sidebar-link">发布项目</a></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#子应用" class="sidebar-link">子应用</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#创建子应用" class="sidebar-link">创建子应用</a></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#删除子应用" class="sidebar-link">删除子应用</a></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#启动子应用开发环境" class="sidebar-link">启动子应用开发环境</a></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#编译子应用" class="sidebar-link">编译子应用</a></li><li class="sidebar-sub-header"><a href="/my/guide/cmd.html#批量编译子应用" class="sidebar-link">批量编译子应用</a></li></ul></li></ul></li><li><a href="/my/guide/coder.html" class="sidebar-link">代码生成器</a></li><li><a href="/my/guide/config.html" class="sidebar-link">配置</a></li><li><a href="/my/guide/constant.html" class="sidebar-link">常量和静态配置</a></li><li><a href="/my/guide/extension.html" class="sidebar-link">内置实例扩展</a></li><li><a href="/my/guide/route.html" class="sidebar-link">自动配置路由</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>内置资源</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>进阶教程</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>第三方类库</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="脚本命令"><a href="#脚本命令" class="header-anchor">#</a> 脚本命令</h1> <p>工程包含了一些开发辅助命令</p> <h2 id="安装依赖"><a href="#安装依赖" class="header-anchor">#</a> 安装依赖</h2> <p>在互联网环境用 <code>npm install</code> 安装，如果安装不成功可以尝试用淘宝镜像</p> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> <span class="token function">install</span> --registry<span class="token operator">=</span>https://registry.npm.taobao.org
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>在非互联网环境安装命令</p> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run <span class="token function">install</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><div class="custom-block warning"><p class="custom-block-title">注意</p> <p>需要在内网环境<a href="/my/guide/config.html#install">部署node_modules</a></p></div> <h2 id="初始化项目"><a href="#初始化项目" class="header-anchor">#</a> 初始化项目</h2> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run ready <span class="token punctuation">[</span>-f<span class="token punctuation">]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>在需要初始化项目临时文件时使用， 该命令会依次运行 修复node_modules、生成ElementUI组件、生成UI主题、生成代码。</p> <p>参数 -f  表示先清除临时目录再创建</p> <h2 id="预编译主题"><a href="#预编译主题" class="header-anchor">#</a> 预编译主题</h2> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run theme <span class="token punctuation">[</span>name<span class="token punctuation">]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>仅编译 ElementUI 主题 <code>npm run theme el</code></p> <p>仅编译 UI 主题 <code>npm run theme ui</code></p> <p>同时编译两者 <code>npm run theme</code></p> <h2 id="生成代码"><a href="#生成代码" class="header-anchor">#</a> 生成代码</h2> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run coder <span class="token punctuation">[</span>-f<span class="token punctuation">]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>当修改了schemas，需要用该命令重新生成代码</p> <p>参数 -f  表示先清除目录再生成代码</p> <h2 id="生成路由配置"><a href="#生成路由配置" class="header-anchor">#</a> 生成路由配置</h2> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run route <span class="token punctuation">[</span>action<span class="token punctuation">]</span> <span class="token punctuation">[</span>app<span class="token punctuation">]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>根据视图组件文件构建路由配置信息</p> <p>action 可选值： <code>build</code> 或 <code>watch</code></p> <p>app 子应用名称，空标识是主应用</p> <h3 id="主应用路由"><a href="#主应用路由" class="header-anchor">#</a> 主应用路由</h3> <p>生成主应用路由配置</p> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run route build
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>监听主应用文件变化自动创建配置</p> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run route <span class="token function">watch</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="子应用路由"><a href="#子应用路由" class="header-anchor">#</a> 子应用路由</h3> <p>生成子应用路由配置</p> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run route build <span class="token punctuation">[</span>子应用名称<span class="token punctuation">]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>监听子应用文件变化自动创建配置</p> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run route <span class="token function">watch</span> <span class="token punctuation">[</span>子应用名称<span class="token punctuation">]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="启动开发环境"><a href="#启动开发环境" class="header-anchor">#</a> 启动开发环境</h2> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run dev
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="编译主应用"><a href="#编译主应用" class="header-anchor">#</a> 编译主应用</h2> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run build
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="启动预览服务"><a href="#启动预览服务" class="header-anchor">#</a> 启动预览服务</h2> <p>在需要检验编译后的应用是否运行正常，可以用该命令启动web服务测试</p> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run preview
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="代码校验"><a href="#代码校验" class="header-anchor">#</a> 代码校验</h2> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run lint
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="运行单元测试"><a href="#运行单元测试" class="header-anchor">#</a> 运行单元测试</h2> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run test:unit
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="构建桥类库"><a href="#构建桥类库" class="header-anchor">#</a> 构建桥类库</h2> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run bridge
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="启动文档服务"><a href="#启动文档服务" class="header-anchor">#</a> 启动文档服务</h2> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run start
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="发布项目"><a href="#发布项目" class="header-anchor">#</a> 发布项目</h2> <p>批量编译打包，包括主应用和全部子应用</p> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run release
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="子应用"><a href="#子应用" class="header-anchor">#</a> 子应用</h2> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run app <span class="token punctuation">[</span>action<span class="token punctuation">]</span> <span class="token punctuation">[</span>name<span class="token punctuation">]</span> <span class="token punctuation">[</span>port<span class="token punctuation">]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="创建子应用"><a href="#创建子应用" class="header-anchor">#</a> 创建子应用</h3> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run app <span class="token function">add</span> <span class="token punctuation">[</span>name<span class="token punctuation">]</span> <span class="token punctuation">[</span>port<span class="token punctuation">]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>例如创建一个 名为 app1 ,启动端口 为 8001</p> <p><code>npm run app add app1 8001</code></p> <h3 id="删除子应用"><a href="#删除子应用" class="header-anchor">#</a> 删除子应用</h3> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run app remove <span class="token punctuation">[</span>name<span class="token punctuation">]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="启动子应用开发环境"><a href="#启动子应用开发环境" class="header-anchor">#</a> 启动子应用开发环境</h3> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run dev:<span class="token punctuation">[</span>name<span class="token punctuation">]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="编译子应用"><a href="#编译子应用" class="header-anchor">#</a> 编译子应用</h3> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run build:<span class="token punctuation">[</span>name<span class="token punctuation">]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="批量编译子应用"><a href="#批量编译子应用" class="header-anchor">#</a> 批量编译子应用</h3> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">npm</span> run app build
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/my/guide/app.html" class="prev">
        子应用微服务
      </a></span> <span class="next"><a href="/my/guide/coder.html">
        代码生成器
      </a>
      →
    </span></p></div> </main></div><div class="global-ui"></div></div>
    <script src="/my/assets/js/app.2dbd0b81.js" defer></script><script src="/my/assets/js/493.009afff8.js" defer></script><script src="/my/assets/js/1350.4706a745.js" defer></script>
  </body>
</html>
